<?php

namespace app\common\model\trait;

trait ConstValid
{
    static int $VALID_INVALID = 0;
    static int $VALID_EFFECT = 1;

    public static function getValidList(): array
    {
        return [
            ["value" => self::$VALID_INVALID, "name" => "禁用"],
            ["value" => self::$VALID_EFFECT, "name" => "启用"],
        ];
    }

    public function getValidTextAttr($value, $data): string
    {
        $text = "";
        $isPass = getValueFromArray("valid", $data);
        if ($isPass == self::$VALID_INVALID) {
            $text = "禁用";
        }
        if ($isPass == self::$VALID_EFFECT) {
            $text = "启用";
        }

        return $text;
    }
}